//package com.org.config;
//
//import com.google.common.cache.Cache;
//import com.google.common.cache.CacheBuilder;
//import org.springframework.stereotype.Component;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * @author: vane.Q
// * @date: 2022/12/4 12:22
// */
//@Component
//public class GuavaCacheConfig {
////    expireAfterAccess(long, TimeUnit)
////    缓存在给定的时间内没有被访问则被回收
////    expireAfterWrite(long, TimeUnit)
////    缓存没有在给定的时间内被写访问（创建或者覆盖）则被回收。
//    private static final Cache<String, Object> CACHE = CacheBuilder.newBuilder()
//            .expireAfterAccess(1800, TimeUnit.SECONDS).maximumSize(1800).build();
//
//    public Object get(String key) {
//        return CACHE.getIfPresent(key);
//    }
//
//    public void set(String key, Object value) {
//        CACHE.put(key, value);
//    }
//
//    public void remove(String key) {
//        CACHE.invalidate(key);
//    }
//
//    public void removeAll() {
//        CACHE.invalidateAll();
//    }
//
//    public long size() {
//        return CACHE.size();
//    }
//
//
//
////    public static void main(String[] args) throws InterruptedException {
////        GuavaCacheConfig cacheConfig = new GuavaCacheConfig();
////        cacheConfig.set("test1", "dsawqe");
////        System.out.println(JsonUtils.objectToJsonString(cacheConfig.status()));
////        Thread.sleep(1000);
////        System.out.println(JsonUtils.objectToJsonString(cacheConfig.status()));
////        Thread.sleep(2000);
////        System.out.println(JsonUtils.objectToJsonString(cacheConfig.status()));
////        Thread.sleep(2000);
////        System.out.println(JsonUtils.objectToJsonString(cacheConfig.get("test1")));
////    }
//}
